﻿using System;
using CardLogistics.Web.Components;
using System.Data;

namespace CardLogistics.Web.Controls
{
    public partial class AppInfo : BasePage
    {
        /// <summary>
        /// 审批人id
        /// </summary>
        protected string UserId = string.Empty;
        /// <summary>
        /// 内容id
        /// </summary>
        protected string InfoId = string.Empty;

        protected string InfoType=string.Empty;

        private static readonly CardLogistics.DAL.Approval.ApprovalInfoData DAL = new DAL.Approval.ApprovalInfoData();
        protected void Page_Load(object sender, EventArgs e)
        {
            InfoId = Request.QueryString["InfoId"];
            UserId = LoggedUser.ID;
            if (!IsPostBack)
            {
                DataTable dt = DAL.GetList(" USERID='" + LoggedUser.ID + "' and INFOID='" + InfoId + "' ", "*");
                if (dt != null && dt.Rows.Count > 0)
                {
                    InfoType = dt.Rows[0]["InfoType"].ToString();
                    APPCONTENT.Value = dt.Rows[0]["APPCONTENT"].ToString();//审批意见
                    if (dt.Rows[0]["APPSTATUS"].ToString() != "0" && dt.Rows[0]["APPSTATUS"].ToString() != "3")//表示改信息已经审批过
                    {
                        d_Sub.Visible = false;
                        d_Info.InnerHtml = "提示：您已于" + dt.Rows[0]["APPDATE"].ToString() + " 对该信息进行了审核！";
                        string appStatus = dt.Rows[0]["APPSTATUS"].ToString();
                        rbappStatus.SelectedValue = appStatus;
                    }
                    else
                    {
                        string appStatus = dt.Rows[0]["APPSTATUS"].ToString();
                        rbappStatus.SelectedValue = appStatus;
                    }
                }
                else
                {
                    //无待审核记录
                    WriteJavaScript("alert('未查询到审核信息,请确保您具有审核权限或该信息已提交！'); $.tipsWindow.removeBox();", false);
                }
            }
        }
        /// <summary>
        /// 向客户端发送Javascript脚本
        /// </summary>
        /// <param name="script"></param>
        internal void WriteJavaScript(string script, bool end)
        {
            Response.Write("<script Language=\"Javascript\">");
            Response.Write(script);
            Response.Write("</");
            Response.Write("script>");
            if (end)
                Response.End();
        }

    }
}